// ex6_9.cpp
#include <iostream>
#include <fstream>
#include <string>

int main(void)
{
	using namespace std;
	const int Grand_Amount = 10000;
	string file_name;
	ifstream inFile;

	struct Patron
	{
		string fullname;
		double money;
	};

	int count = 0;
	cout << "Enter a file name: ";
	getline(cin, file_name);
	inFile.open(file_name, ios::in);
	
	if (inFile.fail())
	{
		cout << "open file failed!\n";
		exit(EXIT_FAILURE);
	}
	
	inFile >> count;
	inFile.get();

	Patron *ptr = new Patron[count];
	for (int i = 0; i < count; i++)
	{
		getline(inFile, ptr[i].fullname);
		inFile >> ptr[i].money;
		inFile.get();
	}
	inFile.close();

	unsigned int max_donation = 0;
	cout << "\nGrand Patron:\n";
	for (int i = 0; i < count; i++)
	{
		if (ptr[i].money > Grand_Amount)
		{
			cout << ptr[i].fullname << ' '
				 << ptr[i].money << endl;
			max_donation++;
		}
	}

	if (max_donation == 0)
		cout << "None" << endl;
	cout << "\nPatron:\n";
	for (int i = 0; i < count; i++)
	{
		if (ptr[i].money < Grand_Amount)
		{
			cout << ptr[i].fullname << ' ';
			if (ptr[i].money == 0)
				cout << "none" << endl;
			else
				cout << ptr[i].money << endl;
		}
	}
	delete[] ptr;
}

